package com.groupbuying.storeinternal.utils;


import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @anthor wenguoqiang
 * @date: 2019/01/15 16:23
 * @company 蒙泰互联网公司
 * @des
 **/


public class ParamUtils {

    private ParamUtils(){}

    //获取请求参数
    public static Map getParamMap(HttpServletRequest request){
        Map map = new HashMap();
        //得到枚举类型的参数名称，参数名称若有重复的只能得到第一个
        Enumeration enums = request.getParameterNames();
        while (enums.hasMoreElements())
        {
            Object tempName =  enums.nextElement();
            if( tempName == null || "".equals(tempName.toString()) ){
                continue;
            }
            String paramName = tempName.toString();
            String paramValue = request.getParameter(paramName);
            //形成键值对应的map
            map.put(paramName, paramValue);
        }
        return map;
    }


    /**
     * 请求参数缺失校验
     * @param request
     * @param params
     */
    public static Object requestParamLackCheck(HttpServletRequest request , List params){
        return null;
    }

}
